

#include "VisualReporter.h"

#include <cstdio>

#include <unistd.h>

#include <sys/time.h>
#include <sys/resource.h>

#include <stdint.h>
#include <time.h>

namespace graph {

using namespace RSIM;

VisualReporter::VisualReporter(const RSIM::SystemData& Data,
        const double& report_interval, GlutMaster * glutMaster,
        GraphWindow * gw) : Reporter(Data, report_interval),
        graphWindow(gw) {
	gm = glutMaster;
	//graphWindow = gw;
}

void VisualReporter::report() const {
	printf("Reporting...\n");
	struct rusage ru;
	getrusage(RUSAGE_SELF, &ru);
	timeval tp = ru.ru_utime;
	timeval tk = tp;

	while (tk.tv_usec - tp.tv_usec <= 50000.0) {
		graphWindow->CallBackDisplayFunc();
		gm->CallGlutMainLoopEvent();
		getrusage(RUSAGE_SELF, &ru);
		tk = ru.ru_utime;
	}

}

}
